package com.huayi.datagovernance.controller;

import com.alibaba.fastjson.JSONObject;
import com.huayi.datagovernance.dto.YzyServiceRequest;
import com.huayi.datagovernance.service.AppService;
import com.huayi.datagovernance.vo.ResponseResult;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * App用户 控制器
 * @version 1.0
 * @date 2021/4/21 15:32
 */
@RestController
@RequestMapping({"/datagovernance/app"})
@Api(tags = "App用户服务",description = "用户相关服务（签到、登录、上传、下载..）")
public class AppController {

    @Resource
    AppService appService;

    /**
     * @api {post} /datagovernance/app/login 1、登录
     * @apiGroup app
     * @apiName login
     * @apiDescription 易作业上的用户映射到本地用户，即登录成功
     * @apiVersion 1.0.0
     * @apiParam {String} appAccount App帐号
     * @apiParam {String} userName 用户名
     * @apiParam {String} orgNo 单位编号
     * @apiParamExample {json} 请求示例：
     * {"data":{"appAccount":"WANGZY60001","deptName":"供电所营业厅","deptNo":"1410444","loginNum":1,"orgName":"下元站","orgNo":"144011212","reserve2":"0","upDate":"2020-07-10 17:07:05","userId":"174079","userName":"王志勇","userStatus":"1","userType":"01"},"serviceCode":"app_login"}
     * @apiSuccess {Boolean} success 是否调用成功
     * @apiSuccess {String} msg 返回消息
     * @apiSuccess {String} data 返回结果
     * @apiSuccessExample {json} 成功返回示例：
     * {"success":true,"msg":"响应成功","data":{"userOrgInfoLevelInfoMap":{"sbzr":"zhangsan","sszrq":"100000","ssdsmc":"国网山西电力公司","orgno":"144011212","orgNo":"144011212","sbzrmc":"张三","whbzmc":"","ssds":"","yxdw":"057252DF34F345E6E050007F01007437","yxdwmc":"国网山西电力公司","whbz":""},"tokenExpiresAt":"1618995793653","userName":"张三","userId":"2da2419f21814cf784e9ba8bb22ec4d4","token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiIyZGEyNDE5ZjIxODE0Y2Y3ODRlOWJhOGJiMjJlYzRkNCIsIm9yZ05vIjoiMTQ0MDExMjEyIiwiaXNzIjoiSFVBWVlJLVNYLURBVEEtTUFOQUdFUiIsImV4cCI6MTYxOTU5Njk5MywidXNlck5hbWUiOiLlvKDkuIkiLCJ1c2VyT3JnSW5mb0xldmVsSW5mbyI6eyJzYnpyIjoiemhhbmdzYW4iLCJzc2RzbWMiOiLlm73nvZHlsbHopb_nlLXlipvlhazlj7giLCJvcmdubyI6IjE0NDAxMTIxMiIsInNienJtYyI6IuW8oOS4iSIsIndoYnptYyI6IiIsInNzZHMiOiIiLCJ5eGR3IjoiMDU3MjUyREYzNEYzNDVFNkUwNTAwMDdGMDEwMDc0MzciLCJ5eGR3bWMiOiLlm73nvZHlsbHopb_nlLXlipvlhazlj7giLCJ3aGJ6IjoiIn0sImlhdCI6MTYxODk5MjE5MywidXNlcklkIjoiMmRhMjQxOWYyMTgxNGNmNzg0ZTliYThiYjIyZWM0ZDQifQ.pjEMJQm-dL9n5sXjIHr_37PRGLO1-7iXNPVc8U8CNGI"}}
     */
    @PostMapping({"/login"})
    ResponseResult login(@RequestBody YzyServiceRequest<JSONObject> serviceInterfaceDto){
        return appService.login(serviceInterfaceDto.getData());
    }
}
